import { post } from '@/request/http'
import { toString } from '@/utils/utils'
import store from '@/store'

/**
 * 平台管理-- 派车中心创建/维护 接口
 *
 */

/**
 * 获取列表数据
 */

export const checksysdepartmentList = ({ dptCode, dptName, PageIndex, dptType, PageSize }) =>
  post('/FTKJWLHYPT/system/getPreDpt', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptCode,
          dptName,
          dptType,
          // fltUuid: -1,
          fltUuid: store.state.user.FLT_UUID_DX_H,
        },
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex,
      },
      PageSize: {
        FTKJWLHYPT: PageSize,
      },
    },
  })
/**
 * 新增一行数据
 */

export const addsysdepartmentList = ({
  // 必填
  dptCode, // 派单中心代码
  dptName, // 派单中心名称
  dptAbbreviation, // 部门简称
  dptFltId, // 企业id
  dptType,
  dptAddress,
  dptPhone,
  dptCorporation,
  dptCorporationId,
  dptBusinessLicenseNo,
  dptSeq, //派车中心序号
  remark = '', // 备注
  dptPredptId, // 上级id
  dptContact, // 联系人
  dptEmail, // 银行卡号
}) =>
  post('/FTKJWLHYPT/system/addSysDepartment', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptCode,
          dptName,
          dptAbbreviation,
          dptFltId,
          dptPredptId,
          dptSeq,
          dptType,
          dptAddress,
          dptPhone,
          dptCorporation,
          dptCorporationId,
          dptBusinessLicenseNo,
          remark,
          dptContact,
          dptEmail,
          creator: store.state.user.USR_CODE_DX_H,
          fltUuid: store.state.user.FLT_UUID_DX_H,
        },
      },
    },
  })
/**
 * 编辑一行数据
 */

export const editsysdepartment = ({
  dptId,
  dptName,
  dptFltId,
  dptAbbreviation,
  dptPredptId,
  dptType,
  dptAddress,
  dptPhone,
  dptCorporation,
  dptCorporationId,
  dptBusinessLicenseNo,
  dptSeq,
  dptEmail,
  version, // 版本号
  remark = '', // 备注
  dptContact, //联系人
}) =>
  post('/FTKJWLHYPT/system/editSysDepartment', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptId,
          dptName,
          dptFltId,
          dptAbbreviation,
          dptPredptId,
          dptSeq,
          dptType,
          dptAddress,
          dptPhone,
          dptCorporation,
          dptCorporationId,
          dptBusinessLicenseNo,
          // 非必填
          remark, // 备注
          dptContact, //联系人
          dptEmail,
          lastModifier: store.state.user.USR_CODE_DX_H,
          version: toString(version),
          fltUuid: store.state.user.FLT_UUID_DX_H,
        },
      },
    },
  })
/**
 * 删除一行数据
 */

export const delsysdepartment = ({
  dptId,
  version, // 版本号
}) =>
  post('/FTKJWLHYPT/system/delSysDepartment', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptId,
          lastModifier: store.state.user.USR_CODE_DX_H,
          version: toString(version),
          fltUuid: store.state.user.FLT_UUID_DX_H,
        },
      },
    },
  })

// 上级机构下拉菜单
export const getCompanysList = ({ dptType }) =>
  post('/FTKJWLHYPT/system/getPreDpt', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H,
          dptType,
        },
      },
    },
  })

// 查看用户
export const checkusersList = ({ dptId, dptFltId, PageIndex, PageSize }) =>
  post('/FTKJWLHYPT/system/querySysUserDepartment', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          dptId,
          dptFltId: store.state.user.FLT_UUID_DX_H,
          fltUuid: store.state.user.FLT_UUID_DX_H,
        },
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex,
      },
      PageSize: {
        FTKJWLHYPT: PageSize,
      },
    },
  })

/* 查询所有派车中心 */
export const checkAllSysDepartment = () =>
  post('/FTKJWLHYPT/system/queryAllDepartment', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          uuid: store.state.user.FLT_UUID_DX_H,
        },
      },
      Orderbys: {},
      PageIndexs: {
        FTKJWLHYPT: '',
      },
      PageSizes: {
        FTKJWLHYPT: '',
      },
    },
  })
